<%@ Page Language="c#" Codebehind="CustomDiscount.aspx.cs" AutoEventWireup="false"
    Inherits="QuoteAdvantage.CustomDiscount" %>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>Custom Discount</title>
    <link href="QuoteAdvantageStyles.css" type="text/css" rel="stylesheet" />

    <script type="text/javascript">
         function onFormLoaded()
         {
            document.Form1.txtPercentageDiscount.select();
            document.Form1.txtPercentageDiscount.focus();
         } 
         
         function onUpdateValuesClicked()
         {
            var bResult = true;
            
            if (document.Form1.txtPercentageDiscount.value != "")
            {
               if (!isValidNumber(document.Form1.txtPercentageDiscount.value))
               {
                  alert("Please enter a valid Percentage Discount");
                  document.Form1.txtPercentageDiscount.focus();
                  bResult = false;
               }
            }
            
            return bResult;  
         }   
         
         function isValidNumber(inpString) 
         {
            inpString = inpString.replace("$", "");
            inpString = inpString.replace("%", "");
            
            return /^[-+]?\d+(\.\d+)?$/.test(inpString);
         } 
         
         function onCancelClicked()
         {
            var bResult = true;
            
            if (document.Form1.txtInitialDiscount.value != document.Form1.txtPercentageDiscount.value
                  || document.Form1.txtInitialTargetPrice.value != document.Form1.txtTargetPrice.value)
            {
               bResult = confirm("Exit without saving changes?");
            }
            
            return bResult;
         }    
    </script>

</head>
<body class="QuoteAdvantagePage" onload="onFormLoaded()">
    <form id="Form1" method="post" runat="server">
        <div class="Toolbar" style="z-index: 101; left: 0px; width: 712px; position: absolute;
            top: 0px; height: 22px">
            <asp:LinkButton ID="lnkCancel" Style="z-index: 103; left: 608px; position: absolute;
                top: 0px" runat="server" CssClass="ToolbarButton" Height="20px" Width="96px">Cancel</asp:LinkButton>
            <asp:LinkButton ID="lnkSave" Style="z-index: 112; left: 504px; position: absolute;
                top: 0px" runat="server" Width="96px" Height="20px" CssClass="ToolbarButton">Save</asp:LinkButton>
        </div>
        <asp:Label ID="Label1" Style="z-index: 109; left: 408px; position: absolute; top: 160px"
            runat="server" CssClass="Label">%</asp:Label>
        <asp:Label ID="lblQuoteTotalValue" Style="z-index: 108; left: 324px; position: absolute;
            top: 124px" runat="server" Width="88px" CssClass="Header" Font-Size="10pt">$1234.00</asp:Label>
        <asp:TextBox ID="txtTargetPrice" Style="z-index: 107; left: 320px; position: absolute;
            top: 184px" runat="server" Width="84px"></asp:TextBox>
        <asp:TextBox ID="txtPercentageDiscount" Style="z-index: 106; left: 320px; position: absolute;
            top: 152px" runat="server" Width="84px"></asp:TextBox>
        <asp:Label ID="Label3" Style="z-index: 104; left: 256px; position: absolute; top: 188px"
            runat="server" CssClass="Label">Target Price:</asp:Label>
        <asp:Label ID="Label2" Style="z-index: 103; left: 216px; position: absolute; top: 156px"
            runat="server" CssClass="Label">Percentage Discount:</asp:Label>
        <asp:Label ID="lblQuoteTotal" Style="z-index: 102; left: 256px; position: absolute;
            top: 124px" runat="server" CssClass="Label">Quote Total:</asp:Label>
        <asp:Button ID="btnUpdateValues" Style="z-index: 105; left: 420px; position: absolute;
            top: 184px" runat="server" Text="Update Values" Width="100px"></asp:Button>
        <input runat="server" style="z-index: 110; left: 280px; position: absolute; top: 320px"
            type="hidden" id="txtInitialDiscount" />
        <input runat="server" style="z-index: 111; left: 280px; position: absolute; top: 348px"
            type="hidden" id="txtInitialTargetPrice" />
    </form>
</body>
</html>
